#pragma once
#include<functional>
#include<queue>
#include<vector>
#include<chrono>
#include<thread>
#include<atomic>
#include<memory>

using time_point = std::chrono::system_clock::time_point;
#define ELM std::pair<time_point, int>

struct Timer{
  static std::function<void(const int &)> worker;
  static std::chrono::duration<int> checkSpan;
  static std::chrono::duration<int> minSpan;
  static std::atomic_flag lock; 
  static std::priority_queue<ELM, std::vector<ELM>, bool(*)(const ELM &, const ELM &)> minHeap;
  Timer(int min = 10);
  static bool cmp(const ELM &a, const ELM &b);
  static void addTask(int t, time_point &time);
  static void check();
};
